#include <SDL/SDL_image.h>
#include "EditorScreen.h"
#include "HUDScreen.h"
#include "MainScreen.h"

using namespace SDL::UTILS;

MainArgs::MainArgs(SDL_Surface* _screen, SDL_Event* _event)
	: ScreenArgs(_screen, _event), LoadSimulator(false)
{
}

MainArgs::~MainArgs()
{
}

MainScreen::MainScreen(SDL_Surface* _screen, SDL_Event* _event) : IScreen(),
	m_backgroundFile("default.png"), m_mapFile(L""),
	m_currentBloc(NULL), m_showGrid(false)
{
	m_screens.Add("hud", new HUDScreen(), HUDScreen::Manage,
				  new HUDArgs(_screen, _event, m_loadedBackground,
						m_backgroundFile, m_mapFile,
						m_currentBloc, m_blocManager, m_showGrid));
	m_screens.Add("editor", new EditorScreen(), EditorScreen::Manage,
				  new EditorArgs(_screen, _event, m_loadedBackground,
						m_currentBloc, m_blocManager, m_showGrid));
	m_loadedBackground.SetSurface(IMG_Load(
						std::string(std::string("Backgrounds\\") +
									m_backgroundFile).c_str()));
	m_currentBloc = m_blocManager.GetOriginals().at("normal");
}

MainScreen::~MainScreen()
{
}

void MainScreen::Draw(IArgs* _datas)
{
	m_screens.Draw(_datas);
}

void MainScreen::Exec(IArgs* _datas)
{
	m_screens.Exec(_datas);
}

bool MainScreen::Manage(ScreenManager::Element* _caller, IArgs* _args)
{
	MainScreen* ms = dynamic_cast<MainScreen*>(_caller->Object);
	ms->m_screens.Manage(_args);
	return (true);
}
